package edu.njust.underwater.controller;

import edu.njust.underwater.common.Result;
import edu.njust.underwater.pojo.User;
import edu.njust.underwater.service.UserService;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class UserController {

    @Resource
    private UserService userService;

    @PostMapping("/login")
    public Result login(User user, HttpSession session) {
        return userService.checkLogin(user, session);
    }

    /**
     * 注册
     * @param user
     * @return
     */
    @PostMapping("/register")
    public Result register(User user, HttpSession session) {

        return userService.register(user, session);

    }
}
